﻿<cfset  paramid = Trim(form.argid) />

<cfset myArr = ArrayNew(1)>

<cfset myArr = ListToArray( paramid , "~", "true") />


<cfset FOLDERCODE = Trim(myArr[1])>
<cfset therightsid = Trim(myArr[2])>



<!---self--->
    

        <cfquery name="getPIDNO" datasource="#client.company_dsn#" maxrows="1">
        
            SELECT #client.mainpk# AS PERSONNELIDNO, FIRSTNAME, LASTNAME FROM #client.MAINTABLE#
             WHERE GUID = '#client.GUID#'
             
        </cfquery>
        
        <cfquery name="getUserInfo" datasource="#client.company_dsn#" maxrows="1">
        
            SELECT AVATAR
              FROM ECRGMYIBOSE
             WHERE PERSONNELIDNO = '#getPIDNO.PERSONNELIDNO#';
             
        </cfquery>
    

        <cfif getUserInfo.AVATAR is "NULL" or getUserInfo.AVATAR eq "">
			<cfset useravatar = "no_avatar.png">
        <cfelse>
            <cfset useravatar = getUserInfo.AVATAR>
        </cfif>
        
        <cfset myfullname     = '#getPIDNO.FIRSTNAME# #getPIDNO.LASTNAME#' />
        <cfset myavatarreal   = '#client.image_path#pics201/#useravatar#' />

		<cfset uuiidd    = CreateUUID() />
		<cfset todaydate = DateFormat(Now(), "YYYY-MM-DD") />
		<cfset todaytime = TimeFormat(Now(), "HH:MM:SS") />
		<cfset todaydate = "#todaydate# #todaytime#" />
		<cfquery name="insertME" datasource="#client.company_dsn#">
			
	<cfquery name="deleteOther" datasource="#client.company_dsn#">
		DELETE FROM ECRTCOLLAB
		 WHERE COLLABCODE = '#therightsid#';
	</cfquery>		
 
	INSERT INTO ECRTCOLLAB ( RIGHTSID, COLLABCODE, ISALLOWED, USERID, COUNT, DATECREATED, USERGRPID_FK, FOLDERCODE )
	VALUES ( '#uuiidd#', '#therightsid#', 'Y', '#client.USERID#', 0, '#todaydate#', '#myfullname#', '#myavatarreal#');
    
 </cfquery>
  
